<script>
class Weather {
  static TYPES = ['☀️', '☁️', '☔️']
  #type // 类型
  #c // 温度（摄氏度）
  #locale // 所在地
  constructor(type, t, locale) {
    this.type = type
    this.locale = locale
    if (this.locale === '中国') {
      this.c = t
    } else {
      this.f = t
    }
  }
  get type() { return this.#type}
  set type(v) {
    if(Weather.TYPES.indexOf(v) > -1) {
      this.#type = v
    }
  }
  get c() { return this.#c}
  set c(v) {
    if (typeof v === 'number') {
      this.#c = v
    }
  }
  // 摄氏度×9/5+32=华氏度
  get f() { return this.c*9/5+32}
  set f(v) {
    if (typeof v === 'number') {
      this.c = (v - 32)*5/9
    }
  }
  get locale() { return this.#locale}
  set locale(v) {
    if (v === '中国' || v === '美国') {
      this.#locale = v
    }
  }
  toString() {
    return `今天天气${this.type}，温度:${
      this.locale === '中国' ? this.c+'摄氏度'
                            : this.f+'华氏度'
    }`
  }
}
const w1= new Weather()
w1.type = Weather.TYPES[0]
w1.c = 20
w1.locale = '美国'
</script>